package org.lql.chaos.mq.rabbitmq.producer;

import lombok.extern.slf4j.Slf4j;
import org.lql.chaos.mq.rabbitmq.constant.RabbitMQConstant;
import org.springframework.amqp.rabbit.connection.CorrelationData;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;

import java.util.UUID;

/**
 * @author: liangqinglong
 * @date: 2025-08-09 11:16
 * @description:
 **/
@Slf4j
@Service
public class BusinessRetryProducer {

	@Autowired
	@Qualifier("rabbitTemplate")
	private RabbitTemplate rabbitTemplate;

	public void sendMessage(String message) {
		CorrelationData cd = new CorrelationData(UUID.randomUUID().toString());
		rabbitTemplate.convertAndSend(
				RabbitMQConstant.BUSINESS_EXCHANGE,
				RabbitMQConstant.BUSINESS_ROUTING_KEY,
				message,
				cd);
		log.info("[BUSINESS_EXCHANGE::{}] 发送消息：{}", RabbitMQConstant.BUSINESS_EXCHANGE, message);
	}
}
